package com.service;
 
import com.proto.*;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;
import java.util.Date;

/**
 * gRPC服务在此处对外暴露出去
 */

@GrpcService
public class GrpcTest01Service extends Service01Grpc.Service01ImplBase {
 
 
    @Override
    public void method01(Method01Request request,
                         StreamObserver<Method01Reply> responseObserver) {
        Method01Reply reply = Method01Reply.newBuilder()
                .setMessage("name：" + request.getName() + ", " + new Date())
                .build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
 
    }
 
    @Override
    public void method02(Method02Request request,
                         StreamObserver<Method02Reply> responseObserver) {
        Method02Reply reply = Method02Reply.newBuilder()
                .setParam1("参数1：" + request.getParam1())
                .setParam2("参数2：" + request.getParam2())
                .build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
 
    }

}